package com.wjv.example.spbt.shiro.config;

import com.wjv.example.common.ResultInfo;
import org.apache.shiro.authz.AuthorizationException;
import org.apache.shiro.authz.UnauthorizedException;
import org.springframework.web.bind.annotation.ControllerAdvice;
import org.springframework.web.bind.annotation.ExceptionHandler;
import org.springframework.web.bind.annotation.ResponseBody;


@ControllerAdvice
public class ShiroExceptionHandler {

    @ExceptionHandler(UnauthorizedException.class)
    @ResponseBody
    public Object unauthorizedException(UnauthorizedException e) {
        return ResultInfo.fail("未经授权");
    }

    @ExceptionHandler(AuthorizationException.class)
    @ResponseBody
    public Object authorizationException(AuthorizationException e) {
        return ResultInfo.fail("未经授权1");
    }
}
